package com.victor.netty.secondexample;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;

/**
 * Created by DJJ on 2019/5/31.
 */
public class MyServer {

    public static void main(String[] args) throws Exception {
        EventLoopGroup boosGroup=new NioEventLoopGroup();//也叫做parent
        EventLoopGroup wokerGroup=new NioEventLoopGroup();//也叫做child

        try {
            ServerBootstrap serverBootstrap=new ServerBootstrap();
            serverBootstrap.group(boosGroup,wokerGroup).channel(NioServerSocketChannel.class)
                    .childHandler(new MyInitializer());
            ChannelFuture channelFuture = serverBootstrap.bind(8899).sync();
            channelFuture.channel().closeFuture().sync();
        } finally {
            boosGroup.shutdownGracefully();
            wokerGroup.shutdownGracefully();
        }
    }
}
